package com.wxy.ej.flow.modules.minio;

import com.rt.easyjava.common.base.Result;
import com.rt.easyjava.common.minio.MinioUtils;
import io.swagger.annotations.Api;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

@Api
@RequestMapping("/minio")
@Controller
public class MinioController {

    @Resource
    private MinioUtils minioUtils;

    /**
     * 上传
     * @param file
     * @return
     */
    @PostMapping("/upload")
    @ResponseBody
    public Result upload(@RequestParam(name = "file", required = false) MultipartFile file) {
        try {
            return minioUtils.uploadFile(file, "product");
        } catch (Exception e) {
            e.printStackTrace();
            return Result.builder().fault("上传失败");
        }
    }


}
